<?php

namespace App\Models;

// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Carbon;
use App\Models\DataTableModel\Folder;
use Illuminate\Database\Eloquent\Collection;

/**
 * Class User
 * 
 * @property int $id
 * @property string $name
 * @property string $email
 * @property Carbon|null $email_verified_at
 * @property string $password
 * @property string $user_type
 * @property string $user_state
 * @property string|null $remember_token
 * @property Carbon|null $created_at
 * @property Carbon|null $updated_at
 * 
 * @property Collection|Folder[] $folders
 *
 * @package App\Models
 */


class User extends Authenticatable
{
	use HasFactory, Notifiable;

	/**  
	 * 指定该模型对应的数据库表名为'users'。  
	 */
	protected $table = 'users';

	/**
	 * The attributes that are mass assignable.
	 *
	 * @var array<int, string>
	 */
	protected $fillable = [
		'name',
		'email',
		'email_verified_at',
		'password',
		'user_type',
		'user_state',
		'remember_token'
	];

	/**
	 * The attributes that should be hidden for serialization.
	 *
	 * @var array<int, string>
	 */
	protected $hidden = [
		'password',
		'remember_token',
	];

	/**
	 * Get the attributes that should be cast.
	 *
	 * @return array<string, string>
	 */
	protected function casts(): array
	{
		return [
			'email_verified_at' => 'datetime',
			'password' => 'hashed',
		];
	}

	/**  
	 * 定义'email_verified_at'字段的类型转换，将其自动转换为'datetime'类型。  
	 */
	protected $casts = [
		'email_verified_at' => 'datetime'
	];

	/**  
	 * 定义一个关联方法，表示一个用户可以拥有多个文件夹（Folder），  
	 * 但这里的'id'应该是Folder表中指向User的外键，通常命名为'id'。  
	 */
	public function folders()
	{
		return $this->hasMany(Folder::class, 'id');
	}
}
